//
//  OrderDetailFirstCell.m
//  ForestPack
//
//  Created by jimmy on 2018/7/22.
//  Copyright © 2018年 郑洲. All rights reserved.
//

#import "OrderDetailFirstCell.h"
#import "Masonry.h"

#pragma mark - 商品预算的cell
@interface OrderDetailFirstCell(){
    UIImageView * leftImageV;
    UILabel *nameLabel;
    UILabel *titleLab;
    UILabel *contentLab1;
    UILabel *contentLab2;
}

@end

@implementation OrderDetailFirstCell

+(OrderDetailFirstCell *)cellWithTableView:(UITableView *)tableView indexPath:(NSIndexPath *)indexPath
{
    static NSString *cellID = @"OrderDetailFirstCell";
    OrderDetailFirstCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
    if (cell == nil) {
        cell = [[OrderDetailFirstCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        cell.backgroundColor = [UIColor whiteColor];
        [cell createSubView];
    }
    return cell;
}

-(void)createSubView
{
    leftImageV = [[UIImageView alloc] init];
    leftImageV.image = [UIImage imageNamed:@"头部背景"];
    leftImageV.contentMode = UIViewContentModeScaleToFill;
    [self addSubview:leftImageV];
    [leftImageV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.mas_left).offset(13);
        make.top.equalTo(self.mas_top).offset(15);
        make.width.equalTo(@140);
        make.height.equalTo(@78);
    }];
    
    nameLabel = [[UILabel alloc] init];
    [nameLabel setText: @"包装纸箱设计"];
    nameLabel.textColor = FONTCOLOR_BLACK;
    nameLabel.font = Kfont(14);
    nameLabel.textAlignment = NSTextAlignmentLeft;
    [self addSubview:nameLabel];
    [nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self->leftImageV.mas_right).offset(10);
        make.top.equalTo(self.mas_top).offset(10);
        make.width.equalTo(@(SCREEN_WIDTH - 163));
        make.height.equalTo(@18);
    }];
    
    titleLab = [[UILabel alloc] init];
    [titleLab setText: @"路人甲包装纸箱设计包装纸箱"];
    titleLab.textColor = RGB_COLOR(153, 153, 153);
    titleLab.font = Kfont(12);
    titleLab.textAlignment = NSTextAlignmentLeft;
    [self addSubview:titleLab];
    [titleLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self->leftImageV.mas_right).offset(10);
        make.top.equalTo(self->nameLabel.mas_bottom).offset(5);
        make.width.equalTo(@(SCREEN_WIDTH - 163));
        make.height.equalTo(@18);
    }];
    
    contentLab1 = [[UILabel alloc] init];
    [contentLab1 setText: @"包装纸箱设计路人甲"];
    contentLab1.textColor = RGB_COLOR(153, 153, 153);
    contentLab1.font = Kfont(12);
    contentLab1.textAlignment = NSTextAlignmentLeft;
    [self addSubview:contentLab1];
    [contentLab1 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self->leftImageV.mas_right).offset(10);
        make.top.equalTo(self->titleLab.mas_bottom).offset(5);
        make.width.equalTo(@(SCREEN_WIDTH - 163));
        make.height.equalTo(@18);
    }];
    
    contentLab2 = [[UILabel alloc] init];
    [contentLab2 setText: @"预算 1999.99元"];
    contentLab2.textColor = RGB_COLOR(237, 34, 59);
    contentLab2.font = Kfont(14);
    contentLab2.textAlignment = NSTextAlignmentRight;
    [self addSubview:contentLab2];
    [contentLab2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.mas_right).offset(-10);
        make.bottom.equalTo(self.mas_bottom).offset(-10);
        make.width.equalTo(@180);
        make.height.equalTo(@18);
    }];
}

- (void)initWithDict:(NSDictionary *)dict {
    [leftImageV sd_setImageWithURL:[NSURL URLWithString:dict[@"pic"]] placeholderImage:nil options:SDWebImageRetryFailed];
    nameLabel.text = dict[@"category"];
    titleLab.text = dict[@"demand"];
    contentLab1.text = @"";
    contentLab2.text = [NSString stringWithFormat:@"预算 %@元",dict[@"total_fee"]];
}

@end


@interface OrderInfoCell()

@end

#pragma mark - 订单信息的cell
@interface OrderInfoCell(){
    UILabel *numLabel;
    UILabel *timeLab1;
    UILabel *timeLab2;
    UILabel *timeLab3;
    UILabel *contentLab2;
}

@end

@implementation OrderInfoCell

+(OrderInfoCell *)cellWithTableView:(UITableView *)tableView indexPath:(NSIndexPath *)indexPath
{
    static NSString *cellID = @"OrderInfoCell";
    OrderInfoCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID ];
    if (cell == nil) {
        cell = [[OrderInfoCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        cell.backgroundColor = [UIColor whiteColor];
        [cell createSubView];
    }
    return cell;
}

-(void)createSubView
{
    UILabel *orderInfo = [[UILabel alloc] init];
    [orderInfo setText: @"订单信息"];
    orderInfo.textColor = FONTCOLOR_BLACK;
    orderInfo.font = Kfont(14);
    orderInfo.textAlignment = NSTextAlignmentLeft;
    [self addSubview:orderInfo];
    [orderInfo mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.mas_left).offset(13);
        make.top.equalTo(self.mas_top).offset(10);
        make.width.equalTo(@(SCREEN_WIDTH - 26));
        make.height.equalTo(@18);
    }];
    
    numLabel = [[UILabel alloc] init];
    numLabel.textColor = RGB_COLOR(153, 153, 153);
    numLabel.font = Kfont(12);
    numLabel.textAlignment = NSTextAlignmentLeft;
    [self addSubview:numLabel];
    [numLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.mas_left).offset(13);
        make.top.equalTo(orderInfo.mas_bottom).offset(10);
        make.width.equalTo(@(SCREEN_WIDTH - 26));
        make.height.equalTo(@18);
    }];
    
    timeLab1 = [[UILabel alloc] init];
    timeLab1.textColor = RGB_COLOR(153, 153, 153);
    timeLab1.font = Kfont(12);
    timeLab1.textAlignment = NSTextAlignmentLeft;
    [self addSubview:timeLab1];
    [timeLab1 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.mas_left).offset(13);
        make.top.equalTo(self->numLabel.mas_bottom).offset(5);
        make.width.equalTo(@(SCREEN_WIDTH - 26));
        make.height.equalTo(@18);
    }];
    
    timeLab2 = [[UILabel alloc] init];
    timeLab2.textColor = RGB_COLOR(153, 153, 153);
    timeLab2.font = Kfont(12);
    timeLab2.textAlignment = NSTextAlignmentLeft;
    [self addSubview:timeLab2];
    [timeLab2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.mas_left).offset(13);
        make.top.equalTo(self->timeLab1.mas_bottom).offset(5);
        make.width.equalTo(@(SCREEN_WIDTH - 26));
        make.height.equalTo(@15);
    }];
    
    timeLab3 = [[UILabel alloc] init];
    timeLab3.textColor = RGB_COLOR(153, 153, 153);
    timeLab3.font = Kfont(12);
    timeLab3.textAlignment = NSTextAlignmentLeft;
    [self addSubview:timeLab3];
    [timeLab3 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.mas_left).offset(13);
        make.top.equalTo(self->timeLab2.mas_bottom).offset(5);
        make.width.equalTo(@(SCREEN_WIDTH - 26));
        make.height.equalTo(@18);
    }];
}

- (void)initWithDict:(NSDictionary *)dict {
    [numLabel setText: [NSString stringWithFormat:@"订单编号：%@",dict[@"order_no"]]];
    [timeLab1 setText: [NSString stringWithFormat:@"创建时间：%@",dict[@"order_time"]]];
    [timeLab2 setText: [NSString stringWithFormat:@"支付时间：%@",dict[@"pay_time"]]];
    [timeLab3 setText: [NSString stringWithFormat:@"发货时间：%@",dict[@"shipping_time"]]];
}

@end

#pragma mark - 商品信息的cell
@interface OrderDetailThirdCell()

@end

@implementation OrderDetailThirdCell

+(OrderDetailThirdCell *)cellWithTableView:(UITableView *)tableView indexPath:(NSIndexPath *)indexPath withTitle:(NSString *)title withDetailInfo:(NSString *)detailInfo
{
    static NSString *cellID = @"OrderDetailThirdCell";
    OrderDetailThirdCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
    if (cell == nil) {
        cell = [[OrderDetailThirdCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        cell.backgroundColor = [UIColor whiteColor];
        [cell createSubViewWithTitle:title withDetailInfo:detailInfo];
    }
    return cell;
}

-(void)createSubViewWithTitle:(NSString *)title withDetailInfo:(NSString *)detailInfo
{
    UILabel *titleLab = [[UILabel alloc] init];
    titleLab.text = title;
    titleLab.textColor = FONTCOLOR_BLACK;
    titleLab.font = Kfont(14);
    titleLab.textAlignment = NSTextAlignmentLeft;
    [self addSubview:titleLab];
    [titleLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.mas_left).offset(13);
        make.top.equalTo(self.mas_top).offset(10);
        make.width.equalTo(@180);
        make.height.equalTo(@24);
    }];
    
    UILabel *detailLab = [[UILabel alloc] init];
    detailLab.text = detailInfo;
    detailLab.textColor = RGB_COLOR(153, 153, 153);
    detailLab.font = Kfont(13);
    detailLab.textAlignment = NSTextAlignmentRight;
    [self addSubview:detailLab];
    [detailLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.mas_right).offset(-13);
        make.top.equalTo(self.mas_top).offset(10);
        make.width.equalTo(@(SCREEN_WIDTH - 180 - 26));
        make.height.equalTo(@24);
    }];
    
    UIImageView *lineImageV = [[UIImageView alloc] init];
    [self addSubview:lineImageV];
    lineImageV.image = [UIImage imageNamed:@"虚线"];
    [lineImageV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.mas_left).offset(13);
        make.top.equalTo(self.mas_bottom).offset(-1);
        make.width.equalTo(@(SCREEN_WIDTH - 26));
        make.height.equalTo(@1);
    }];
}
@end

